<?php
//if (isset($_SESSION['username'])) {
include_once 'header_tongji.php';
require_once("../conn.php");
require_once("../change_page.php");
require_once 'common.php';
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv= "Content-Type" content= "text/html; charset=utf-8" charset= "utf-8 "/>
        <title>乐知家园</title>
        <style type="text/css">
            <!--
            body,td,th {
                font-family: 微软雅黑;
                font-size: 14px;
                color: #000000;
            }

            .STYLE1 {color: #FFFFFF}
            -->
        </style></head>
    <body>
        <br/>
        <table width="80%" border="0" align="center" cellpadding="1" cellspacing="1" bgcolor="#FFFFFF">
            <tr align="align">
                <td bgcolor="#FFFFFF">&nbsp;</td>
                <td bgcolor="#FFFFFF" align="left">&nbsp;</td>
                <td>&nbsp;</td>
                <td bgcolor="#FFFFFF" align="right"><?php
                $page_size = 50;
                $page = getParameter("page");
                if ($page == "") {
                    $page = 0;
                }
                $keyword = getParameter("keyword");
                $age_sql_where = "";
                $age_sql_and = "";
                if ($keyword != "") {
                    $sql = "SELECT COUNT(*) AS total FROM t_device WHERE (email LIKE '%" . $keyword . "%' OR nickname LIKE '%" . $keyword . "%')" . $age_sql_and;
                } else {
                    $sql = "SELECT COUNT(*) AS total FROM t_device " . $age_sql_where;
                }

                $db = new DBC();
                $total_num = $db->fetchData($sql);
                if ($total_num != null) {
                    $total_num_product = $total_num[0]['total'];
                }
                $page_count = getPageSize($total_num_product, $page_size);
                echo getPage("tongji_yonghu_list.php?menu=tongji_yonghu_list", $page_count, $page);
                ?></td>
            </tr>
        </table>
        <br/>
        <table width="80%" border="0" align="center" cellpadding="1" cellspacing="1" bgcolor="#9999FF">
            <tr align="center">
                <td bgcolor="#666666"><span class="STYLE1">序号</span></td>
                <td bgcolor="#666666"><span class="STYLE1">ID</span></td>
                <td bgcolor="#666666"><span class="STYLE1">性别</span></td>
                <td bgcolor="#666666"><span class="STYLE1">昵称</span></td>
                <td bgcolor="#666666"><span class="STYLE1">邮箱</span></td>
                <td bgcolor="#666666"><span class="STYLE1">状态</span></td>
                <td bgcolor="#666666"><span class="STYLE1">系统</span></td>
                <td bgcolor="#666666"><span class="STYLE1">启动次数</span></td>
                <td bgcolor="#666666"><span class="STYLE1">答题次数</span></td>
                <td bgcolor="#666666"><span class="STYLE1">题包数</span></td>
                <td bgcolor="#666666"><span class="STYLE1">胜率</span></td>
                <td bgcolor="#666666"><span class="STYLE1">金币</span></td>
                <td bgcolor="#666666"><span class="STYLE1">现金消费</span></td>
                <td bgcolor="#666666"><span class="STYLE1">最后启动时间</span></td>
                <td bgcolor="#666666"><span class="STYLE1">最后答题时间</span></td>
                <td bgcolor="#666666"><span class="STYLE1">操作</span></td>
            </tr>
            <?php
            $begin = $page * $page_size;
            if ($keyword != "") {
                $sql = "SELECT * FROM t_device WHERE (nickname LIKE '%" . $keyword . "%' OR email LIKE '%" . $keyword . "%') " . $age_sql_and . " ORDER BY deviceid LIMIT " . $begin . "," . $page_size;
            } else {
                $sql = "SELECT * FROM t_device " . $age_sql_where . " ORDER BY deviceid LIMIT " . $begin . "," . $page_size;
            }
            $num = $begin;
            $data = $db->fetchData($sql);
            foreach ($data as $product) {
                $usercode = $product['devicecode']; 
                if(strlen($usercode)>6){
                    $usercode = substr($usercode, 0, 6);
                }
                if ($product['status'] == "0") {
                    $status = "<font color='brown'>未发布</font>";
                } else if ($product['status'] == "1") {
                    $status = "<font color='green'>已发布</font>";
                } else if ($product['status'] == "-1") {
                    $status = "<font color='red'>已下线</font>";
                }else{
                    $status = "<font color='black'>无</font>";
                }
                ?>
                <tr>
                    <td bgcolor="#FFFFFF">&nbsp;<?php echo++$num; ?></td>
                    <td bgcolor="#FFFFFF">&nbsp;<?php echo $usercode; ?></td>
                    <td bgcolor="#FFFFFF">&nbsp;<?php echo $product['sex']; ?></td>
                    <td bgcolor="#FFFFFF">&nbsp;<?php echo $product['nickname']; ?></td>
                    <td bgcolor="#FFFFFF">&nbsp;<?php echo $product['email']; ?></td>
                    <td align="center" bgcolor="#FFFFFF"><?php echo $status; ?></td>
                    <td align="center" bgcolor="#FFFFFF"><?php echo $product['os']; ?></td>
                    <td align="center" bgcolor="#FFFFFF"><?php echo $status; ?></td>
                    <td align="center" bgcolor="#FFFFFF"><?php echo $status; ?></td>
                    <td align="center" bgcolor="#FFFFFF"><?php echo $status; ?></td>
                    <td align="center" bgcolor="#FFFFFF"><?php echo $product['gold']; ?></td>
                    <td align="center" bgcolor="#FFFFFF"><?php echo $product['gold']; ?></td>
                    <td align="center" bgcolor="#FFFFFF"><?php echo $product['gold']; ?></td>
                    <td align="center" bgcolor="#FFFFFF"><?php echo $product['gold']; ?></td>
                    <td align="center" bgcolor="#FFFFFF"><?php echo $product['gold']; ?></td>
                    <td align="center" bgcolor="#FFFFFF"><a href="musicEdit.php?menu=music&flashid=<?php echo $product['productid']; ?>">查看</a></td>
                </tr>
            <?php } ?>
        </table>
    </body>
</html>
<?php
include_once '../footer.php';
//} else {
//    header("login.php");
//}
?>